﻿<?php 
include_once("../function.php");
//print_r($_GET);//Array ( [uid] => 4 [oid] => 131 [pid] => 155,158 )
extract($_GET);
//print_r($_COOKIE);//Array ( [pwd] => 123456 [rem] => on [PHPSESSID] => bbqtine8sjpklb0kgvd2qii298 [usname] => wanmingming [username] => wanmingming )
//$username=$_COOKIE['usname']；
//$sql="select * from ts_o"
?>
<!doctype html>
<html>
 <head>
  <title>我的订单</title>
  <meta charset="utf-8"/>
    <style>
  *{margin:0px;padding:0px;}
#big{
	 width:100%;
	 height:780px;
	 border:1px solid red;
	 margin:20px auto;
	}
ul{
	 list-style-type:none;float:left;
	}
li{
	float:left;
	margin-left:15px;
	font-size:0.5em;
	color:#a5a5a5;
	
	}
span{
	float:right;
	}
.p0{
	margin-left:20px;
	}
.xs{
	margin-left:20px;
	height:50px;
	width:auto;
	border:0px solid red;
	}
.xc1{
	font-size:2em;
	margin-right:50px;
	}
#xw{
	width:100%;
	height:40px;
	border:1px solid;
	background:#1F81B0;
	line-height:40px;
	font-size:2.5em;
	
	}
	ul a:-webkit-any-link {text-decoration:none;
    color:white;
    cursor: pointer;}
ul li{margin-left:35px;
    color:white;
	
}
 	
#fl{
	margin-left:50px;
	font-size:1.3em;
	}
#s{float:left;margin-left:30px;font-size:20px;width:200px;height:20px;}
#middle{width:100%;height:auto;border:0px solid red;}
#order{width:500px;height:auto;margin-top:50px;margin-left:500px;}
a{text-decoration:none;color:black;}
table{border-color:#e4e4e4;}

</style>
 </head>

 <body>
<?php include_once("./login_top.php");?>
<div id="s">
	<span class="sp1"><font color="#b6b6b6">当前所在></font>我的订单</span>
</div>
<div id="middle">
	<div id="order">
		<table width="1000px" height="auto" border=2 cellspacing=0 rules="rows">
			<tr>
				<th>订单编号</th>
				<th>订单时间</th>
				<th>订单总额</th>
				<th>付款状态</th>
				<th>收货状态</th>
				<th>操作</th>
				<th></th>
			</tr>
			<?php $sql="select * from ts_user where username='$_COOKIE[username]'";
					$res=mysqli_query($link,$sql);
					$uid=mysqli_fetch_assoc($res)['uid'];
					$sql="select * from ts_order where user_id=$uid";
					$res=mysqli_query($link,$sql);
					if(is_object($res))
					{
						if(mysqli_num_rows($res)>0)
						{
							$arr=array();
							while(($list=mysqli_fetch_assoc($res))!=false)
							{
								$arr[]=$list;
							}
						}
					}
			?>
			<?php if(isset($arr)){foreach($arr as $v){?>
			<tr>
				<td align="center"><?=$v['order_sn']?></td>
				<td align="center"><?=date("Y-m-d H:i:s",$v['order_time'])?></td>
				<td align="center"><?=$v['subtotal']?></td>

				<td align="center">
				<?php if($v['pay_status']==0){?>
				<font color="blue" size="4">未付款<a href="./do_zhifu.php?oid=<?=$v['order_id']?>&uid=<?=$v['user_id']?>">去付款</a></font>
				<?php }elseif($v['pay_status']==1){?>
					<font color="#33cc00">已付款</font>
				<?php }?>
					</td>

				<td align="center"><?php if($v['delivery_status']==0){echo '<font color="blue" size="4">未发货</font>';}elseif($v['delivery_status']==1){echo "<font color='green'><a href='do_shouhuo.php?order_id=$v[order_id]'>确认收货</a></font>";}else{echo '<font color="green">已收货</font>';}?></td>
				<td align="center"><font color="#ffcc33" class="order_detail">订单详情</font></td>
				<td></td>
			</tr>
			<tr class="order_details" style="display:none">
				<td colspan=7>
					<table width="1000px" height="auto" border=0 cellspacing=0 rules="rows">
						<tr bgcolor="#e6e6e6">
							<th>商品图片</th>
							<th>商品名称</th>
							<th>商品价格</th>
							<th>商品颜色</th>
							<th>商品尺寸</th>
							<th>商品数量</th>
							<th>操作</th>
						</tr>
						<?php $sql="select * from ts_order_goods where oid=$v[order_id]";
							
						$res=mysqli_query($link,$sql);
						if(is_object($res))
						{
							if(mysqli_num_rows($res)>0)
							{
								$arr2=array();
								while(($list=mysqli_fetch_assoc($res))!=false)
								{
									$arr2[]=$list;
								}
							}
						}
							
									
						foreach($arr2 as $k){?>
						<tr>
							<?php $sql="select * from ts_product where pid='$k[pid]'";
							$res=mysqli_query($link,$sql);
							$list=mysqli_fetch_assoc($res); ?>
							<td><img src="../<?=$list['thumb']?>" width="80px" height="70px"></td>							
							<td><?=$list['pname']?></td>
							<td><?=$list['price']?></td>
							<td><?=$k['color']?></td>
							<td><?=$k['size']?></td>
							<td><?=$k['num']?></td>
							<td>
								<?php
								//是否已收获
								$sql="select * from ts_order where order_id=$k[oid] and delivery_status=2";
								$res=mysqli_query($link,$sql);
								$res=mysqli_fetch_assoc($res);
								if($res){
									//是否已评价
									$sql="select * from ts_order_goods where o_pid=$k[o_pid] and msg_id!=0";
									$res=mysqli_query($link,$sql);
									$res=mysqli_fetch_assoc($res);
									if($res){
								?>
									<span>评价完成</span>
								<?php }else{ ?>
									<a href="message.php?o_pid=<?=$k["o_pid"]?>">去评论</a>
								<?php }} ?>
							</td>
						</tr>
						<?php } ?>						
					</table>
				</td>
			</tr>
			<?php }} ?>
		</table>
	</div>
</div>	
<div style="margin-top:50px;"><hr></div>
</div>	
	<div style="clear:both;width:100%;height:150px;border:0px solid yellow;">
	<?php $sql="select * from ts_news_cate where level=1";
		  $res=mysqli_query($link,$sql);
		  if(is_object($res))
		  {
			  if(mysqli_num_rows($res)>0)
			  {
				$arr=array();
				while(($one=mysqli_fetch_assoc($res))!=false)
				  {
				  $arr[]=$one;
				  }
				 }?>
					
				<?php foreach($arr as $v){?>
				<div style="float:left;margin-left:250px;border:0px solid red;font-size:16px;margin-top:7px;"><div style="border:px solid blue;font-size:19px;margin-left:-8px;"><?=$v["cname"]?></div>
					<?php $sql="select * from ts_news_cate where fid=$v[cid]";
					$res=mysqli_query($link,$sql);
					if(is_object($res))
					 {
						$arr2=array();
						while(($one1=mysqli_fetch_assoc($res))!=false)
						 {
							$arr2[]=$one1;
						 }
						foreach($arr2 as $vo)
						 {?>
							<div><a href="news.php?cid=<?=$vo['cid']?>"><?=$vo["cname"]?></a></div>
						<?php }
					}?>
						</div>
			<?php }
					
			 }
	?>
</div>
		
<hr color="#e5e5e5"/>
<div id="db">
	<div style="margin-left:800px;margin-top:10px;">
			关于我们|法律声明|工作机会|联系我们
	</div>

	<div style="margin-left:600px;margin-top:20px;color:#a8a8a8;">
		Copyright@2013 Thinksite Co.Let night reserved 经营许可证编号：苏A-12345678
	</div>
</div>
<script type="text/javascript">
order_detail=document.getElementsByClassName("order_detail");
order_details=document.getElementsByClassName("order_details");
for(let i=0;i<order_detail.length;i++)
{
	order_detail[i].onclick=function()
	{
		if(order_details[i].style.display=="none")
		{
		order_details[i].style.display="table-row";
		}
		else
		{
			order_details[i].style.display="none"
		}
	}
}
</script>
 </body>
</html>
